<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="../inc.jsp"></jsp:include>
<style type="text/css">
#myTable {
	width: 275px;
	padding: 0px;
	margin: 8px;
}

#myTd {
	border-top: 1px solid #f5f5f5;
	border-left: 1px solid #f5f5f5;
	border-right: 1px solid #f5f5f5;
	border-bottom: 1px solid #f5f5f5;
	background: #fff;
	font-size: 15px;
	padding: 6px 6px 6px 12px;
	color: #4f6b72;
}
</style>
<script type="text/javascript">
	//dataGrid数据绑定
	$(function() {
		$('#xyl_bys_datagrid').datagrid({
			url : '${pageContext.request.contextPath}/school/studentAction!datagrid.action',
			fit : true,
			fitColumns : true,
			border : false,
			rownumbers : true,
			pagination : true,
			idField : 'stuId',
			singleSelect:true,
			//checkOnSelect : false,
			columns : [ [ {
				field : 'id',
				title : '编号',
				width : 150,
				align : 'center',
				checkbox : true,
				sortable : true
			}, {
				field : 'stuId',
				title : '学号',
				width : 150,
				align : 'center',
				sortable : true,
			}, {
				field : 'stuName',
				title : '姓名',
				width : 150,
				align : 'center',
				sortable : true
			}, {
				field : 'stuSex',
				title : '性别',
				width : 80,
				align : 'center'
			}, {
				field : 'bornDate',
				title : '出生日期',
				width : 200,
				align : 'center',
				sortable : true
			}, {
				field : 'className',
				title : '所属班级 ',
				width : 150,
				align : 'center',
				sortable : true
			}, {
				field : 'isSpecial',
				title : '特殊校友',
				width : 150,
				align : 'center',
				formatter : function(value, row, index) {
					return '<img src="${pageContext.request.contextPath}/jslib/images/icons/accept.png" onclick="PassApply()">标记</img>';
				}
			} ] ],
			toolbar : [ {
				text : '查看所有',
				iconCls : 'icon-reload',
				handler : function() {
					searchAllFun();
				}
			}, '-', {
				text : '添加',
				iconCls : 'icon-add',
				handler : function() {
					append();
				}
			}, '-', {
				text : '编辑',
				iconCls : 'icon-edit',
				handler : function() {
					edit();
				}
			}, '-', {
				text : '删除',
				iconCls : 'icon-remove',
				handler : function() {
					remove();
				}
			} ]
		});
		$('#bys_dateTime').datetimebox({
			value : '11/5/2013 2:3',
			required : true,
			showSeconds : false
		});
		$('#bys_edit_dateTime').datetimebox({
			value : '11/5/2013 2:3',
			required : true,
			showSeconds : false
		});
		$('#bys_classCmb').combobox({
			url : '${pageContext.request.contextPath}/school/classAction!getClassCmb.action',
			valueField : 'className',
			textField : 'className'
		});
		$('#bys_class2Cmb').combobox({
			url : '${pageContext.request.contextPath}/school/classAction!getClassCmb.action',
			valueField : 'className',
			textField : 'className'
		});
	});

	//查询按钮
	function searchFun() {
		$('#xyl_bys_datagrid').datagrid('load', {
			stuName : $('#xyl_bys_searchPnl input[name=stuName]').val(),
			stuId : $('#xyl_bys_searchPnl input[name=stuID]').val(),
			className : $('#xyl_bys_searchPnl input[name=className]').val(),
			CollegeName : $('#xyl_bys_searchPnl input[name=CollegeName]').val(),
			majorName : $('#xyl_bys_searchPnl input[name=majorName]').val(),
			gradeName : $('#xyl_bys_searchPnl input[name=gradeName]').val()
		});
	}
	function searchAllFun() {
		$('#xyl_bys_searchPnl input[name=stuId]').val('');
		$('#xyl_bys_searchPnl input[name=stuName]').val('');
		$('#xyl_bys_datagrid').datagrid('load', {});
	}
	function append() {
	//	$('#xyl_bys_addForm input').val('');
		$('#xyl_bys_addForm input[name=stuId]').val('');
		$('#xyl_bys_addForm input[name=stuName]').val('');
		$('#xyl_bys_addForm input[name=className]').val('');
		$('#xyl_bys_addForm input[name=identityCard]').val('');
		$('#xyl_bys_addForm input[name=homeTel]').val('');
		$('#xyl_bys_addForm input[name=phone]').val('');
		$('#xyl_bys_addForm input[name=address]').val('');
		$('#xyl_bys_addDialog').dialog('open');
	}
	function remove() {
		var rows=$('#xyl_bys_datagrid').datagrid('getChecked');
		var Ids=[];
		if(rows.length>0){
			$.messager.confirm('确认','是否确认删除选中的记录？',function(r){
			if(r){
				for(var i=0;i<rows.length;i++){
					Ids.push(rows[i].id);
				}
				$.ajax({
					url:'${pageContext.request.contextPath}/school/studentAction!remove.action',
					data:{Ids:Ids.join(',')},
					dataType:'json',
					success:function(r){
						$('#xyl_bys_datagrid').datagrid('load');
						$('#xyl_bys_datagrid').datagrid('unselectAll');
						$.messager.show({
							title:'提示',
							msg:r.msg
						});
					}
				});
			}
		});
		}else{
			$.messager.alert('提示','请选择你要操作的行!');
		}
	}
	function edit(){
		$('#xyl_bys_editForm input[name=stuId]').val('');
		$('#xyl_bys_editForm input[name=stuName]').val('');
		$('#xyl_bys_editForm input[name=className]').val('');
		$('#xyl_bys_editForm input[name=identityCard]').val('');
		$('#xyl_bys_editForm input[name=homeTel]').val('');
		$('#xyl_bys_editForm input[name=phone]').val('');
		$('#xyl_bys_editForm input[name=address]').val('');
		var rows = $('#xyl_bys_datagrid').datagrid('getChecked');
		if (rows.length == 1) {
			$('#xyl_bys_editForm').form('load',rows[0]);
			$('#xyl_bys_editDialog').dialog('open');
		} else {
			$.messager.alert('提示', '请选择你要操作一行!');
		}
	}
	function PassApply(){
		$.messager.confirm('确认', '是否添加为特殊校友？', function(r) {
			if (r) {
				$('#xyl_tsxy__datagrid').datagrid('clearSelections');
				$('#xyl_tsxy__datagrid').datagrid('load');
				var node = $('#xyl_bys_datagrid').datagrid('getSelected');
				if(null!=node.isSpecial&&node.isSpecial.trim()=="否"){
					$.ajax({
						url : '${pageContext.request.contextPath}/school/specialAction!add.action',
						data : {schoolmateId:node.stuId,
								  schoolmateName:node.stuName,
								  schoolmateSex:node.stuSex,
								  schoolmateCollege:node.className,
								  isSpecial:'是',
								  schoolmateBorn:node.bornDate,
								  schoolmateType:'学生'
								 },
						dataType : 'json',
						success : function(r) {
									$('#xyl_tsxy__datagrid').datagrid('load');
									$('#xyl_tsxy__datagrid').datagrid('unselectAll');
									$.messager.show({
										title : '提示',
										msg : r.msg
									});
							}
					});
				}else{
					$.messager.alert('提示','该校友已标记为特殊校友!');
				}
			}
		});
	}
</script>
</head>
<body>
<div id="xyl_bys_layout" class="easyui-layout" data-options="fit:true">
	<div data-options="region:'center',head:false,border:false">
		<div class="easyui-layout" data-options="fit:true,border:false">
			<div id="xyl_bys_searchPnl" data-options="region:'north',border:false" style="fit:true;overflow:hidden;background-color:#F5F5F5;">
				<table>
					<tr>
						<td style="padding:5px 5px 5px 15px;">姓名 ：<input name="stuName" style="width:100px;" />
						</td>
						<td style="padding:5px 5px 5px 15px;">学号：<input name="stuID" style="width:100px;" />
						</td>
						<td style="padding:5px 5px 5px 15px;"><a href="#" class="easyui-linkbutton" data-options="border:false,iconCls:'icon-search',plain:true" onclick="searchFun()">查询</a>
						</td>
					</tr>
				</table>
			</div>
			<div data-options="region:'center'" style="height:200px;">
				<table id="xyl_bys_datagrid"></table>
			</div>
		</div>
	</div>
</div>
<div id="xyl_bys_addDialog" class="easyui-dialog" style="width:450px;height:450px;padding:0px 0px 0px 0px;" data-options="closed:true,modal:true,title:'添加',buttons:[{
			text:'确定',
			iconCls:'icon-ok',
			handler:function(){
				$('#xyl_bys_addForm').form('submit',{
				url:'${pageContext.request.contextPath}/school/studentAction!add.action',
				success:function(data){
					var obj=jQuery.parseJSON(data);
					if(obj.success){
						$('#xyl_bys_datagrid').datagrid('load');
						$('#xyl_bys_addDialog').dialog('close');
					}
					$.messager.show({
						title:'提示',
						msg:obj.msg
					});
				}});
			}
		}]">
	<form id="xyl_bys_addForm" method="post">
		<div id="xyl_bys_Tabs" class="easyui-tabs" data-options="fit:true,border:false" style="width:450px;height:300px;">
			<div title="基础">
				<table id="myTable">
					<tr>
						<td id="myTd">学号：</td>
						<td><input type="text" name="stuId" class="easyui-validatebox"  data-options="required:true,validType:'number',missingMessage:'必填！'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">姓名：</td>
						<td><input type="text" name="stuName" class="easyui-validatebox"  data-options="required:true,validType:'name',missingMessage:'必填！'">
						</td>
					</tr>
					<tr>
						<td id="myTd">性别：</td>
						<td><input name="stuSex"  checked value="男"  type="radio"></input>男<input name="stuSex"  value="女"  type="radio"></input>女</td>
					</tr>
					<tr>
						<td id="myTd">出生日期：</td>
						<td><input id="bys_dateTime" type="text" name="bornDate"></input></td>
					</tr>
					<tr>
						<td id="myTd">所属班级：</td>
						<td><input type="text" name="className" id="bys_classCmb"  data-options="required:true,editable:false,missingMessage:'必填！'" >
						</td>
					</tr>
				</table>
			</div>
			<div title="个人">
				<table id="myTable">
					<tr>
						<td id="myTd">身份证：</td>
						<td><input type="text" class="easyui-validatebox" name="identityCard"  data-options="validType:'idcard'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">宅电：</td>
						<td><input type="text" class="easyui-validatebox" name="homeTel"  data-options="validType:'phone'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">手机：</td>
						<td><input type="text" name="phone" class="easyui-validatebox" data-options="validType:'mobile'">
						</td>
					</tr>
					<tr>
						<td id="myTd">住址：</td>
						<td><input type="text" name="address"  class="easyui-validatebox"  data-options="validType:'length[0,50]'">
						</td>
					</tr>
				</table>
			</div>
		</div>
	</form>
</div>
<div id="xyl_bys_editDialog" class="easyui-dialog" style="width:450px;height:450px;padding:0px 0px 0px 0px;" data-options="closed:true,modal:true,title:'编辑',buttons:[{
			text:'确定',
			iconCls:'icon-ok',
			handler:function(){
				$('#xyl_bys_editForm').form('submit',{
				url:'${pageContext.request.contextPath}/school/studentAction!edit.action',
				success:function(data){
					var obj=jQuery.parseJSON(data);
					if(obj.success){
						$('#xyl_bys_datagrid').datagrid('load');
						$('#xyl_bys_editDialog').dialog('close');
					}
					$.messager.show({
						title:'提示',
						msg:obj.msg
					});
				}});
			}
		}]">
	<form id="xyl_bys_editForm" method="post">
		<div id="xyl_bys_Tabs2" class="easyui-tabs" data-options="fit:true,border:false" style="width:450px;height:350px;">
			<div title="基础">
				<table id="myTable">
					<tr style="display:none">
						<td >编号：</td>
						<td><input type="text" name="id" >
						</td>
					</tr>
					<tr>
						<td id="myTd">学号：</td>
						<td><input type="text" name="stuId" class="easyui-validatebox"  data-options="required:true,validType:'number',missingMessage:'必填！'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">姓名：</td>
						<td><input type="text" name="stuName" class="easyui-validatebox"  data-options="required:true,validType:'name',missingMessage:'必填！'">
						</td>
					</tr>
					<tr>
						<td id="myTd">性别：</td>
						<td><input name="stuSex" value="男" type="radio" checked>男<input name="stuSex" value="女" type="radio">女</td>
					</tr>
					<tr>
						<td id="myTd">出生日期：</td>
						<td><input id="bys_edit_dateTime" type="text" name="bornDate"></input></td>
					</tr>
					<tr>
						<td id="myTd">所属班级：</td>
						<td><input type="text"  name="className"  id="bys_class2Cmb"  data-options="required:true,editable:false,missingMessage:'必填！'" >
						</td>
					</tr>
				</table>
			</div>
			<div title="个人">
				<table id="myTable">
					<tr>
						<td id="myTd">身份证：</td>
						<td><input type="text" class="easyui-validatebox" name="identityCard"  data-options="validType:'idcard'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">宅电：</td>
						<td><input type="text" class="easyui-validatebox" name="homeTel"  data-options="validType:'phone'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">手机：</td>
						<td><input type="text" name="phone" class="easyui-validatebox" data-options="validType:'mobile'" >
						</td>
					</tr>
					<tr>
						<td id="myTd">住址：</td>
						<td><input type="text" name="address"  class="easyui-validatebox"  data-options="validType:'length[0,50]'" >
						</td>
					</tr>
				</table>
			</div>
		</div>
	</form>
</div>
</body>
</html>


